<?php

namespace app\common\enum;

class PayEnum
{
    //支付类型
    const WECHAT_PAY  = 1; //微信支付
    const ALI_PAY     = 2; //支付宝支付
    const BALANCE_PAY = 3; //余额支付
    const CASH_PAY    = 4; //线下支付
    //支付状态
    const UNPAID = 0; //未支付
    const ISPAID = 1; //已支付

    //支付标识
    const PAY_FOR = [
        'alipay_app' => '支付宝APP支付',
        'alipay_h5' => '支付宝手机网站支付',
        'alipay_scan' => '支付宝扫码支付',
        'alipay_pos' => '支付宝条码支付',
        'alipay_applet' => '支付宝小程序支付',
        'alipay_web' => '支付宝电脑网站支付' ,
        'wx_app' => '微信APP支付',
        'wx_mp' => '微信JSAPI支付',
        'wx_scan' => '微信Native支付',
        'wx_pos' => '微信付款码支付',
        'wx_h5' => '微信H5支付',
        'wx_applet' => '微信小程序支付'
    ];

    /**
     * 获取支付标识
     * @param bool $value
     * @return string|string[]
     */
    public static function getPayForDesc($value = true)
    {
        $data = self::PAY_FOR;
        if ($value === true) {
            return $data;
        }
        return $data[$value] ?? '';
    }

    /**
     * 获取支付类型
     * @param bool $value
     * @return string|string[]
     */
    public static function getPayDesc($value = true)
    {
        $data = [
            self::WECHAT_PAY => '微信支付',
            self::ALI_PAY => '支付宝支付',
        ];
        if ($value === true) {
            return $data;
        }
        return $data[$value] ?? '';
    }

    /**
     * 获取支付状态
     * @param bool $value
     * @return string|string[]
     */
    public static function getPayStatusDesc($value = true)
    {
        $data = [
            self::UNPAID => '未支付',
            self::ISPAID => '已支付',
        ];
        if ($value === true) {
            return $data;
        }
        return $data[$value] ?? '';
    }
}